//封装所有和用户相关的接口函数
import httpInstance from "@/utils/http";

export const loginAPI = ({ username, password }) => {
    return httpInstance({
        url: '/user/login',
        method: 'Post',
        data: {
            username,
            password
        }
        /*headers: {
            "Content-Type": "application/json",
        },
        params: {
            username,
            password
        }*/
    })
}

export const testAPI = () => {
    return httpInstance({
        url: '/user/test-session',
        method: 'Get'
    })
}

//分页查询
export const pageAPI = ({ currentPage, pageSize, username, gender, phoneNumber }) => {
    return httpInstance({
        url: '/user/page',
        method: 'Get',
        params: {
            currentPage,
            pageSize,
            username,
            gender,
            phoneNumber
        }
    })
}

//启用或禁用用户
export const changeStateAPI = (id, state) => {
    return httpInstance({
        url: `/user/state/${state}/`,
        method: 'Put',
        params: {
            id
        }
    })
}

//删除用户
export const deleteUserAPI = (id) => {
    return httpInstance({
        url: `/user/${id}`,
        method: 'Delete'
    })
}

//新增用户
export const addUserAPI = (data) => {
    return httpInstance({
        url: '/user/add',
        method: 'Post',
        data
    })
}

//更新用户
export const updateUserAPI = (data) => {
    return httpInstance({
        url: `/user/${data.id}`,
        method: 'Put',
        data
    })
}


//导出用户
export const exportUserDataAPI = (params) => {
    return httpInstance({
        url: '/user/export',
        method: 'Get',
        params,
        responseType: 'blob'
    })
}




